<template>
  <div class="data">
    <el-form label-width="80px" class="form-item">
      <el-form-item label="用户名">
        <el-input v-model="userList.username"></el-input>
      </el-form-item>
      <el-form-item label="密碼">
        <el-input v-model="userList.password" type="password"></el-input>
      </el-form-item>
      <el-form-item label="目标院校">
        <el-input v-model="userList.tschool"></el-input>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="userList.email"></el-input>
      </el-form-item>
      <el-form-item label="qq号码">
        <el-input v-model="userList.qq"></el-input>
      </el-form-item>
      <el-form-item label="手机号码">
        <el-input v-model="userList.telphone"></el-input>
      </el-form-item>
      <el-form-item>
        <el-radio v-model="userList.sex" label="男">男</el-radio>
        <el-radio v-model="userList.sex" label="女">女</el-radio>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import addUserApi from "@/api/ky";
export default {
  data() {
    return {
      userList: {
        username: "",
        password: "",
        tschool: "",
        email: "",
        qq: "",
        telphone: "",
        sex: "男",
      },
    };
  },
  methods: {
    onSubmit() {
      // this.$emit("userPage")
      //this.$refs[this.userList.userinfo].resetFields();
      addUserApi.addUser(this.userList).then((res) => {
        if (res.data.flag==true) {
          this.$message({
            type: 'success',
            message: res.data.message
          });
        } else {
          this.$message.error('用户添加失败');
        }
      });
    },
  },
};
</script>

<style>
.data {
  width: 100%;
  height: 100%;
}
.form-item {
  width: 30%;
  margin: auto;
}
</style>